﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Timers;
using Oracle.ManagedDataAccess.Client;
using System.Text.RegularExpressions;

using System.Diagnostics;
using System.Collections.Concurrent;
using System.IO;
using SharpDB;
using SharpDB.Entity;
using System.Data.SqlClient;
using System.Data.Common;
using System.Xml.Linq;
using Microsoft.Win32;
using System.Net;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Linq.Expressions;


namespace SharpDB_ConsoleApp
{
   
   
    class Program
    {
        static void Main(string[] args)
        {
            DB db = new DB(AccessType.MsSql);           

            DBInfo dbInfo = db.Info;

         

            Console.WriteLine();
        }

        static Random rdom = new Random();

        static void ExecDesc()
        {
            DB db = new DB(AccessType.MsSql);
            DBInfo dbInfo = db.Info;
            string strSql = "SELECT TABLE_ID,TABLE_NAME,DESCRIPTION FROM dbo.DICT_DATA_TABLE";
            DataTable data = db.QueryTable(strSql);
            foreach (DataRow dr in data.Rows)
            {
                string tabName = dr["TABLE_NAME"].ToString();
                string desc = dr["DESCRIPTION"].ToString();
                if (dbInfo.IsExistTable(tabName))
                {
                    dbInfo.UpsertTableComment(tabName, desc);

                    string table_Id = dr["TABLE_ID"].ToString();
                    strSql = @"SELECT b.FIELD_CODE,b.FIELD_NAME FROM dbo.DICT_DATA_COLUMNS a 
LEFT JOIN dbo.DICT_DATA_FIELD b ON a.FIELD_ID = b.FIELD_ID
where a.TABLE_ID = '{0}'";
                    strSql = string.Format(strSql, table_Id);

                    DataTable data_col = db.QueryTable(strSql);

                    foreach (DataRow drCol in data_col.Rows)
                    {
                        string fieldCode = drCol["FIELD_CODE"].ToString();
                        string fieldName = drCol["FIELD_NAME"].ToString();

                        if (dbInfo.IsExistColumn(tabName, fieldCode))
                        {
                            dbInfo.UpsertColumnComment(tabName, fieldCode, fieldName);
                        }
                    }

                }
            }
        }

        static void SW(Action act)
        {
            Stopwatch wat = new Stopwatch();
            wat.Start();
            act.Invoke();
            wat.Stop();
            long lenTime = wat.ElapsedMilliseconds;
            Console.WriteLine(lenTime);
        }
    }
}
